package aes

import (
	"fmt"
	"github.com/agclqq/goencryption"
)

//var plainTextStr = "lovegoencryption"
var keyStr = "ro1thd8vj80WwZGJBhylLgO9CDFVPUlS"
var ivStr = "poiuytre12345678"

func Encrypt(plainTextStr string) string {
	//使用aes-cbc-pkcs7进行加密,并用base64输出
	cryptText, err := goencryption.EasyEncrypt("aes/cbc/pkcs7/base64", plainTextStr, keyStr, ivStr)
	if err != nil {
		fmt.Println(err)
		return cryptText
	}
	fmt.Println(cryptText)

	return cryptText
}

func Decrypt(cryptText string) string {
	//使用base64转码,并用aes-cbc-pkcs7进行解密
	text, err := goencryption.EasyDecrypt("aes/cbc/pkcs7/base64", cryptText, keyStr, ivStr)
	if err != nil {
		fmt.Println(err)
		return text
	}
	fmt.Println(text)
	return text
}
